package tx.bjdacp.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bjdacp.model.*;
import tx.bjdacp.dao.*;
import tx.bjdacp.service.*;
import tx.bjdacp.vo.query.*;


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class SampleInfoDao extends BaseHibernateDao<SampleInfo,java.lang.Integer>{

	public Class getEntityClass() {
		return SampleInfo.class;
	}

	public Page findPage(SampleInfoQuery query) {
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接
        // [column] 为PageRequest的属性
		String sql = "select t from SampleInfo t where 1=1 "
			  	+ "/~ and t.drugSellUnitId = {drugSellUnitId} ~/"
			  	+ "/~ and t.sampleNumber like '%[sampleNumber]%' ~/"
				+ "/~ and t.sampleDate >= {sampleDateBegin} ~/"
				+ "/~ and t.sampleDate <= {sampleDateEnd} ~/"
			  	+ "/~ and t.sampledUnitName like '%[sampledUnitName]%' ~/"
			  	+ "/~ and t.unitKind like '%[unitKind]%' ~/"
			  	+ "/~ and t.sampleUnit like '%[sampleUnit]%' ~/"
			  	+ "/~ and t.sampleProduct like '%[sampleProduct]%' ~/"
			  	+ "/~ and t.productType like '%[productType]%' ~/"
			  	+ "/~ and t.amount like '%[amount]%' ~/"
			  	+ "/~ and t.batchNumber like '%[batchNumber]%' ~/"
			  	+ "/~ and t.sampleKind like '%[sampleKind]%' ~/"
			  	+ "/~ and t.reportNumber like '%[reportNumber]%' ~/"
				+ "/~ and t.reportDate >= {reportDateBegin} ~/"
				+ "/~ and t.reportDate <= {reportDateEnd} ~/"
			  	+ "/~ and t.reportResult like '%[reportResult]%' ~/"
				+ "/~ and t.receiveReportDate >= {receiveReportDateBegin} ~/"
				+ "/~ and t.receiveReportDate <= {receiveReportDateEnd} ~/"
			  	+ "/~ and t.sampleYear = {sampleYear} ~/"
			  	+ "/~ and t.drugSellUnit.unitName like '%[drugSellUnit_unitName]%' ~/"
				+ "/~ order by [sortColumns] ~/";


		return pageQuery(sql,query);
	}


}
